/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Calendar;
import java.util.Date;

/**
 * <p>Project: jse2204 - Arr1
 * <p>Powered by webrx On 2022-09-06 10:56:26
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr1 {
    public static void main(String[] args) {

        //数组对象 是引用类型，会自动的初始化，元素的个数是固定的
        //String[] args 字符串数组
        int[] ns = {1, 2, 3, 4, 5};
        int[] nn = new int[5];//数组元素下标0 1 2 3 4
        double[] ds = new double[]{1.0, 2.0, 3.3};
        //数组
        Date[] dd = new Date[5];
        char[] chars = "hello".toCharArray();
        String[] wks = "日一二三四五六".split("");
        var ls = "java,python,php,html,css,javascript,mysql,c,linux".split(",");

        //使用数组（操作）
        System.out.println(ns[4]);
        System.out.println("今日是：星期"+wks[Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1]);

        nn[4] = 600;
        System.out.println(nn[4]);
        System.out.println(nn[1]);

        System.out.println(dd[0]); //null

        //遍历数组
        System.out.println(ds.length); //数组对象的属性，返回一个int数字，代表当前数组的元素个数
        for(double d : ds){
            System.out.println(d);
        }

        System.out.println();
        System.out.println(ls.length);
        for (int i = 0; i < ls.length; i++) {
            System.out.printf("%d、%s ",i+1,ls[i]);
        }
        System.out.println();
        System.out.println();
        for (int i = ls.length - 1; i >= 0; i--) {
            System.out.println(ls[i]);
        }



    }
}
